<?php session_start(); $_SESSION['page'] = 'news';?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN">

<?php
    require('db_connection.php');
    $userType = $_COOKIE['userType'];

    if($userType == 'superadministrator')
    {
        $query = "SELECT * FROM tbladmin ORDER BY libraryNo";
    }
    else
    {
        $libraryNo = $_COOKIE['libraryNo'];
        $query = "SELECT * FROM tbladmin WHERE libraryNo=$libraryNo and userType='administrator' or userType='staff'";
    }

    $result = mysql_query($query);
    
    $qnews = "SELECT MAX(newsID) FROM tblnews";
    $rnews = mysql_query($qnews);
    while ($row = mysql_fetch_array($rnews))
    {
        $ctr1=$row['MAX(newsID)'];
    }
?>

<html>

   <head>
      <title>News Result</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
      <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>

    <table width='80%' align='center' class='content'>
        <tr><td colspan='2'><img src='images/banner.jpg'></td></tr>
        <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
        <tr class='menuborder'><td width='90%'><img src='images/news!.png'></td><td><?php  require('buttons.php'); ?></td></tr>
        <tr><td colspan='2' class='bodyborder'>
        <?php echo "<form method='post' action='delete.php?page=news&newsCtr=$ctr1'>";?>
        <table align='center' cellspacing='0' width='80%'>
        <?php
            $ctr = 1;
            echo "<tr><td height='30'></td></tr>";
            echo "<tr class='listtable'><td></td><th width='20%'>News ID</th><th>Title</th><th>Author</th></tr>";
            $qnews = "SELECT * FROM tblnews";
            $rnews = mysql_query($qnews);
            while ($row = mysql_fetch_array($rnews))
            {
              $newsID = $row['newsID'];
              $author = $row['author'];
              $title = $row['title'];

              echo "<tr><td class='listborder' width='5%'><input type='checkbox' name='news[$ctr]' value=$newsID></td>";
              echo "<td class='listborder' width='10%'><a href='admindetail.php?newsID=$newsID'>$newsID</td>";
              echo "<td class='listborder' width='50%'>$title</td>";
              echo "<td class='listborder' width='35%'>$author</td>";
              $ctr++;
              $news[$ctr] = $newsID;
            }
              echo "<tr><td height='15'></td></tr>";
              echo "<tr><td colspan='5' align='right'><input type='submit' value='Delete' class='tool'>";
              echo "</form>";
        ?>
        </table>

            </td>
        </tr>
        <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
    </table>

   </body>
</html>

